package hash相关.q1_两数之和.f1;

/**
 * 暴力法 o(n^2)
 */
class Solution {
    public int[] twoSum(int[] nums, int target) {
        int[] result = new int[2];
        for (int i = 0; i < nums.length; i++) {
            for (int j = i + 1; j < nums.length; j++) {
                if (nums[i] + nums[j] == target) {
                    result[0] = i;
                    result[1] = j;
                    return result;
                }
            }
        }
        return null;
    }
}


class Solution {
    // 暴力
    public int[] twoSum(int[] nums, int target) {
        int[] res = new int[2];
        int len=nums.length;
        for(int i=0;i<=len-1;i++){
            for(int j=i+1;j<=len-1;j++){
                if(nums[i]+nums[j]==target){
                    res[0]=i;
                    res[1]=j;
                    return res;
                }
            }
        }
        return res;
    }

}